export default {
  data() {
    return {
      // Model
      passwordModel: {
        title: 'Change Password',
        visible: false,
        confirmLoading: false,
        ref: 'changePasswordRef'
      },

      bindMailModel: {
        title: 'Bind Mailbox',
        visible: false,
        confirmLoading: false,
        ref: 'bindMailboxBindRef'
      },

      authMailModel: {
        title: 'authMailModel',
        visible: false,
        confirmLoading: false,
        ref: 'authMailModelRef'
      },

      bindMobileModel: {
        title: 'Bind Mobile Phone Number',
        visible: false,
        confirmLoading: false,
        ref: 'bindPhoneRef'
      },

      // props
      modalProps: {
        cancelText: 'Cancel',
        okText: 'Submit',
        // getContainer() {
        //   return document.querySelector('#appMain')
        // },
        okButtonProps: {
          props: {
            shape: 'round'
          }
        },
        cancelButtonProps: {
          props: {
            shape: 'round'
          }
        }
      }
    };
  },

  methods: {
    // modal submit  this.form.resetFields();
    modalSubmit(prop) {
      const _ref = this.$refs[prop.ref];

      prop.confirmLoading = true;
      _ref.handleSubmit()
        .then(async () => {
          try {
            this.$notification.success({
              message: 'Modified successfully!',
              duration: 1
            });
            prop.visible = false;
            _ref.resetFields();

            _ref.submitCallBack();
          } catch (error) {
            console.error(error);
          }
        })
        .finally(() => {
          prop.confirmLoading = false;
        });
    },

    // modal cancel
    modalCancel(prop) {
      prop.visible = false;

      const _ref = this.$refs[prop.ref];

      _ref.resetFields();
    }
  }
};
